package exception;

import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: Hua YY
 * Date: 2025-06-16
 * Time: 10:25
 */


/*
* 哇靠闭环了，自定义异常类
* 尤其是在调用checkLength()这个方法，进行异常捕获的时候*/
public class Main {

    public static void checkLength() throws StringException {
        String str;
        Scanner scanner = new Scanner(System.in);
        str = scanner.nextLine();
        int length = str.length();
        if(length < 5){
            throw new StringException(length);
        }else{
            System.out.println("字符串的长度是" + length);
        }
    }

    public static void main(String[] args) {
        try {
            Main.checkLength();
        } catch (StringException e) {
            System.out.println("当前字符串的长度是"+e.getLength());
        }
    }
}
